/*******************************************************************************
 * Copyright (c) 2012 Philip Douglas.
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 ******************************************************************************/
package net.pdouglas.revisiondroid;

import android.os.Parcel;
import android.os.Parcelable;

import net.pdouglas.revision.Timer;

public class TimerState implements Parcelable {
	private Timer mTimer;

	public int mode = Timer.MODE_OFF;
    public int reviseTime = 0;
    public int relaxTime = 0;

	public TimerState(Timer timer) {
		this.mTimer = timer;
	}

	public int describeContents() {
		return 0;
	}

	public void writeToParcel(Parcel out, int flags) {
        synchronized (mTimer) {
        	out.writeInt(mTimer.getMode());
            out.writeInt(mTimer.getReviseTime());
            out.writeInt(mTimer.getRelaxTime());
        }
	}

    public static final Parcelable.Creator<TimerState> CREATOR
            = new Parcelable.Creator<TimerState>() {
        public TimerState createFromParcel(Parcel in) {
            return new TimerState(in);
        }

        public TimerState[] newArray(int size) {
            return new TimerState[size];
        }
    };

    private TimerState(Parcel in) {
    	mode	   = in.readInt();
        reviseTime = in.readInt();
        relaxTime  = in.readInt();
    }
}
